﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace AMPSDAO.DAO.DatabaseManagement
{
    public enum DatabaseType
    { 
        SqlServer,
        MySQL
    }

    public class IParamenter:IDataParameter
    {

        public IParamenter()
        {

        }

        public IParamenter(string name, DbType dbtype,int size, object value)
        {
            this.ParameterName = name;
            this.DbType = dbtype;
            this.Value = value;
            this.Size = size;
        }

        public IParamenter(string name, DbType dbtype,int size, object value, ParameterDirection direction)
        {
            this.ParameterName = name;
            this.DbType = dbtype;
            this.Value = value;
            this.Direction = direction;
            this.Size = size;
        }

        public int Size { get; set; }

        public DbType DbType
        {
            get;
            set;
        }

        public ParameterDirection Direction
        {
            get;
            set;
        }

        public bool IsNullable
        {
            get { return (this.Value == null); }
        }

        public string ParameterName
        {
            get;
            set;
        }

        public string SourceColumn
        {
            get;
            set;
        }

        public DataRowVersion SourceVersion
        {
            get;
            set;
        }

        public object Value
        {
            get;
            set;
        }
    }

    interface IDatabaseClient
    {
        IDbTransaction Transaction { get; set; }
        IDbConnection Connection { get; set; }
        IDbConnection getConnection();
        int ExecuteCreateCommand(string select_cmd);
        IDataReader ExecuteSelectCommand(string select_cmd);
        IDataReader ExecuteSelectCommand(string select_cmd, IParamenter[] param);
        IDataReader ExecuteSelectCommand(string select_cmd, IParamenter[] param, IParamenter[] paramcondition = null);
        IDataReader ExecuteSelectCommand(string select_cmd, List<IParamenter> param = null);
        DataSet GetDataSetFormSelectCommand(string select_cmd);
        DataSet GetDataSetFormSelectCommand(string select_cmd, IParamenter[] param);
        DataSet GetDataSetFormSelectCommand(string select_cmd, IParamenter[] param, IParamenter[] paramcondition = null);
        DataSet GetDataSetFormSelectCommand(string select_cmd, List<IParamenter> param = null);
        int ExecuteInsertCommand(string insertCmd);
        int ExecuteInsertCommand(string insertCmd, IParamenter[] param);
        int ExecuteInsertCommand(string select_cmd, IParamenter[] param, IParamenter[] paramcondition = null);
        int ExecuteInsertCommand(string insertCmd, List<IParamenter> param = null);
        string SelectCommand { get; }
        string UpdateCommand { get; }
        string DeleteCommand { get; }
        string InsertCommand { get; }
        void Open();
        void Commit();
        void RollBack();
        void CloseConnection(bool unsafeclose = false);
        List<IParamenter> GetParameter();
        long GetAutoIncrement(string tablename);
    }
}
